package com.ruoyi.product.service.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 场景ID类型
 */
@Getter
public enum WarehouseTypeEnum
{

    HOT(1, "信用贷")
    ,LIST(2, "抵押贷")
    ,MINE(3, "企微页面")
    ,MATCH(4, "匹配页面")
    ,OVER(5, "贷超页")
    ;

    private Integer value;
    private String key;

    WarehouseTypeEnum(Integer value, String key)
    {
        this.value = value;
        this.key = key;
    }


    public static List<Map<String, String>> getSceneMapList(){
        List<Map<String, String>> resultList = new ArrayList<>();
        for (WarehouseTypeEnum typeEnum : values()) {
            Map<String, String> itemMap = new HashMap<>();
            itemMap.put("key", typeEnum.getKey());
            itemMap.put("value", String.valueOf(typeEnum.getValue()));
            resultList.add(itemMap);
        }
        return resultList;
    }

    public static String getNameByValue(Integer chargeType) {
        for (WarehouseTypeEnum typeEnum : values()) {
            if (ObjectUtil.equals(chargeType, typeEnum.getValue())){
                return typeEnum.getKey();
            }
        }
        return String.valueOf(chargeType);
    }

    public static String getValueByName(Integer value) {
        for (WarehouseTypeEnum typeEnum : values()) {
            if (ObjectUtil.equals(value, typeEnum.getValue())){
                return typeEnum.getKey();
            }
        }
        return String.valueOf(value);
    }

    public static Integer getNameByValue(String name) {
        for (WarehouseTypeEnum typeEnum : values()) {
            if (ObjectUtil.equals(name, typeEnum.getKey())){
                return typeEnum.getValue();
            }
        }
        return null;
    }

}
